package com.wmyg.antifake.entity;

import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author 王卓逸
 * @program TODO
 * @description TODO
 * @create 2019-05-05
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@Table(name = "bk_factory")
public class Factory {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "factory_id")
    private Integer factoryId;

    @Column(name = "factory_name")
    private String factoryName;

    @Column(name = "factory_address")
    private String factoryAddress;

    @Column(name = "contract")
    private String contract;

    @Column(name = "phone")
    private String phone;

    @Lob
    @Column(name = "factory_pics")
    private String factoryPics;

    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.EAGER)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "company_id")
    private Company company;

    @CreatedDate
    @Column(name = "create_time")
    private Date createTime;

    @LastModifiedDate
    @Column(name = "modify_time")
    private Date modifyTime;

}
